package bishi.dada;

import java.util.Scanner;

/**
 * @author: 唐小尊
 * @email: 1171702529@qq.com
 * @cate: 2021/09/05 17:00
 */
public class two {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        str = str.replace(" ", "");
        String[] split = str.split("\\|");
        String[] split1 = split[0].split(",");
        String[] split2 = split[1].split(",");
        int left = 0;
        int right = 0;
        StringBuilder sb = new StringBuilder();
        while (left < split1.length || right < split2.length) {
            int now1 = left == split1.length ? Integer.MAX_VALUE : Integer.parseInt(split1[left]);
            int now2 = right == split2.length ? Integer.MAX_VALUE : Integer.parseInt(split2[right]);
            if (now1 < now2) {
                sb.append(now1).append(",");
                left++;
            } else if (now1 > now2) {
                sb.append(now2).append(",");
                right++;
            } else {
                sb.append(now1).append(",").append(now2).append(",");
                right++;
                left++;
            }
        }
        if (sb.length()>0){
            sb.delete(sb.length()-1, sb.length());
        }
        System.out.println(sb.toString());
    }
}
